<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:p="http://primefaces.org/ui"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:pe="http://primefaces.org/ui/extensions">

    <h:body>

        <ui:composition template="/resources/template/template.xhtml">

            <ui:define name="content">
                <h:form>

                    <p:panel header="ALL B.H.T. TOTAL PAYMENT  SUMMERIES" >

                        <h:panelGrid columns="5" >
                            <p:outputLabel value="Date"/>
                            <p:calendar value="#{mdInwardReportController.fromDate}" pattern="dd/MMM/yyyy - hh:mm:ss a" ></p:calendar>
                            <p:outputLabel value="From" ></p:outputLabel>

                            <p:calendar value="#{mdInwardReportController.toDate}" pattern="dd/MMM/yyyy - hh:mm:ss a" ></p:calendar>
                            <h:outputLabel value="To" ></h:outputLabel>
                        </h:panelGrid>

                        <h:panelGrid columns="2">    
                            <p:outputLabel value="Admission Type"/>
                            <p:selectOneMenu value="#{mdInwardReportController.admissionType}">
                                <f:selectItem itemLabel="All Admission Type"/>
                                <f:selectItems  value="#{mdInwardReportController.admissionTy}" var="myItem" 
                                                itemValue="#{myItem}" itemLabel="#{myItem.name}"></f:selectItems>
                            </p:selectOneMenu>

                            <p:outputLabel value="B.H.T. Type"/>
                            <p:selectOneMenu   id="cmbPs" value="#{mdInwardReportController.paymentMethod}">
                                <f:selectItem itemLabel="All Bht Type" />                           
                                <f:selectItems value="#{enumController.paymentMethodForAdmission}" />

                            </p:selectOneMenu>

                            <p:outputLabel value="Credit Company"/>
                            <p:autoComplete id="creditCom" forceSelection="true" 
                                            value="#{mdInwardReportController.creditCompany}"  
                                            completeMethod="#{creditCompanyController.completeCredit}" var="ix" 
                                            itemLabel="#{ix.name}" itemValue="#{ix}" size="30"  style="width: 400px;">
                            </p:autoComplete>
                        </h:panelGrid>



                        <p:panelGrid columns="3">
                            <p:commandButton ajax="false" value="Fill" action="#{mdInwardReportController.allBhtTotPySummerries()}" onclick="onSubmitButton();" ></p:commandButton>

                            <p:commandButton value="Print" ajax="false" action="#" >
                                <p:printer target="gpBillPreview" ></p:printer>
                            </p:commandButton>

                            <p:commandButton ajax="false" value="Excel" styleClass="noPrintButton" style="float: right;" onclick="onSubmitButton();" actionListener="#{mdInwardReportController.allBhtTotPySummerries()}">
                                <pe:exporter type="xlsx" target="tbl,tbl2,tbl3" fileName="Payment_of_Undischarge_Patient" />
                            </p:commandButton>  
                        </p:panelGrid>


                        <h:panelGroup id="gpBillPreview">
                            <p:dataTable id="tbl" styleClass="noBorder normalFont" value="#{mdInwardReportController.bil}" var="i"  >
                                <f:facet name="header">
                                    <h:outputLabel value="Total Payment Summary - #{mdInwardReportController.admissionType} -  #{mdInwardReportController.paymentMethod}"/>

                                    <h:outputLabel value="From  "/>
                                    <h:outputLabel value="#{mdInwardReportController.fromDate}">
                                        <f:convertDateTime pattern="dd/MM/yy &nbsp; hh:mm:ss a" ></f:convertDateTime>
                                    </h:outputLabel>
                                    <h:outputLabel value="--   To  "/>
                                    <h:outputLabel value="#{mdInwardReportController.toDate}">
                                        <f:convertDateTime pattern="dd/MM/yy &nbsp; hh:mm:ss a" ></f:convertDateTime>
                                    </h:outputLabel>

                                </f:facet>

                                <p:column headerText="B H T No">
                                    <f:facet name="header">
                                        <h:outputLabel value="B H T No"/>
                                    </f:facet>
                                    <h:outputLabel value="#{i.patientEncounter.bhtNo}" ></h:outputLabel>
                                </p:column>

                                <p:column headerText="Bill No">
                                    <f:facet name="header">
                                        <h:outputLabel value="Bill No"/>
                                    </f:facet>
                                    <h:outputLabel value="#{i.insId}" ></h:outputLabel>
                                    <h:outputLabel value="/" rendered="#{i.cancelledBill ne null}" ></h:outputLabel>
                                    <h:outputLabel value="#{i.cancelledBill.insId}" style="color: red;" rendered="#{i.cancelledBill ne null}" ></h:outputLabel>
                                </p:column>

                                <p:column headerText="Patient Name">
                                    <f:facet name="header">
                                        <h:outputLabel value="Patient Name"/>
                                    </f:facet>
                                    <h:outputLabel value="#{i.patient.person.nameWithTitle} - #{i.patientEncounter.creditCompany.name}" ></h:outputLabel>
                                </p:column>

                                <p:column headerText="Date">
                                    <f:facet name="header">
                                        <h:outputLabel value="Date"/>
                                    </f:facet>                                    
                                    <h:outputLabel value="#{i.createdAt}"  >
                                        <f:convertDateTime pattern="dd/MM/yy" ></f:convertDateTime>
                                    </h:outputLabel>
                                </p:column>

                                <p:column>
                                    <f:facet name="header">
                                        <h:outputLabel value="Payment Methord"/>
                                    </f:facet>                                    
                                    <h:outputLabel value="#{i.paymentMethod.label}" />
                                </p:column>

                                <p:column headerText="Amount" style="text-align: right;">
                                    <f:facet name="header">
                                        <h:outputLabel value="Amount"/>
                                    </f:facet>  
                                    <p:outputLabel value="#{i.netTotal}" >
                                        <f:convertNumber pattern="#,##0.00" />
                                    </p:outputLabel>
                                </p:column>

                                <p:column headerText="Comment">
                                    <f:facet name="header">
                                        <h:outputLabel value="Comment"/>
                                    </f:facet>                                    
                                    <h:outputLabel  value="#{i.comments}">
                                    </h:outputLabel>
                                </p:column>

                                <p:columnGroup type="footer">

                                    <p:row>

                                        <p:column colspan="5" footerText="Total"></p:column>
                                        <p:column footerText="#{mdInwardReportController.totalValue}" style="text-align: right">
                                            <f:facet name="footer">
                                                <p:outputLabel value="#{mdInwardReportController.totalValue}">
                                                    <f:convertNumber pattern="#,##0.00"></f:convertNumber></p:outputLabel>
                                            </f:facet>
                                        </p:column>
                                        <p:column ></p:column>

                                    </p:row>

                                </p:columnGroup>

                            </p:dataTable>

                            <p:dataTable id="tbl2" styleClass="noBorder normalFont" value="#{mdInwardReportController.cancel}" 
                                         var="can">

                                <p:column headerText="B H T No">
                                    <f:facet name="header">
                                        <h:outputLabel value="B H T No"/>
                                    </f:facet>
                                    <h:outputLabel value="#{can.patientEncounter.bhtNo}" ></h:outputLabel>
                                </p:column>

                                <p:column headerText="Bill No">
                                    <f:facet name="header">
                                        <h:outputLabel value="Bill No"/>
                                    </f:facet>
                                    <h:outputLabel value="#{can.insId}" ></h:outputLabel>
                                </p:column>
                                <p:column headerText="Cancel Bill No">
                                    <f:facet name="header">
                                        <h:outputLabel value="Payment Bill No"/>
                                    </f:facet>
                                    <h:outputLabel value="#{can.billedBill.insId}" style="color: red;"></h:outputLabel>
                                </p:column>
                                <p:column headerText="Patient Name">
                                    <f:facet name="header">
                                        <h:outputLabel value="Patient Name"/>
                                    </f:facet>
                                    <h:outputLabel value="#{can.patient.person.nameWithTitle}" ></h:outputLabel>
                                </p:column>

                                <p:column headerText="Date">
                                    <f:facet name="header">
                                        <h:outputLabel value="Date"/>
                                    </f:facet>                                    
                                    <h:outputLabel value="#{can.createdAt}"  >
                                        <f:convertDateTime pattern="dd/MM/yy" ></f:convertDateTime>
                                    </h:outputLabel>
                                </p:column>

                                <p:column>
                                    <f:facet name="header">
                                        <h:outputLabel value="Payment Methord"/>
                                    </f:facet>                                    
                                    <h:outputLabel value="#{can.paymentMethod.label}" />
                                </p:column>

                                <p:column headerText="Amount" style="text-align: right;">
                                    <f:facet name="header">
                                        <h:outputLabel value="Amount"/>
                                    </f:facet>                                    
                                    <p:outputLabel value="#{can.netTotal}" >
                                        <f:convertNumber pattern="#,##0.00" />
                                    </p:outputLabel>
                                </p:column>

                                <p:column headerText="Comment">
                                    <f:facet name="header">
                                        <h:outputLabel value="Comment"/>
                                    </f:facet>                                    
                                    <h:outputLabel  value="#{can.comments}">
                                    </h:outputLabel>
                                </p:column>

                                <p:columnGroup type="footer">

                                    <p:row>

                                        <p:column colspan="6" footerText="Total"></p:column>
                                        <p:column footerText="#{mdInwardReportController.cancelledTotal}" style="text-align: right">
                                            <f:facet name="footer">
                                                <p:outputLabel value="#{mdInwardReportController.cancelledTotal}">
                                                    <f:convertNumber pattern="#,##0.00"></f:convertNumber>
                                                </p:outputLabel>
                                            </f:facet>
                                        </p:column>
                                        <p:column ></p:column>
                                    </p:row>

                                </p:columnGroup>


                            </p:dataTable>

                            <p:dataTable id="tbl3" styleClass="noBorder normalFont" value="#{mdInwardReportController.refund}" 
                                         var="ref">

                                <p:column headerText="B H T No">
                                    <f:facet name="header">
                                        <h:outputLabel value="B H T No"/>
                                    </f:facet>
                                    <h:outputLabel value="#{ref.patientEncounter.bhtNo}" ></h:outputLabel>
                                </p:column>

                                <p:column headerText="Bill No">
                                    <f:facet name="header">
                                        <h:outputLabel value="Bill No"/>
                                    </f:facet>
                                    <h:outputLabel value="#{ref.insId}" ></h:outputLabel>
                                </p:column>

                                <p:column headerText="Patient Name">
                                    <f:facet name="header">
                                        <h:outputLabel value="Patient Name"/>
                                    </f:facet>
                                    <h:outputLabel value="#{ref.patient.person.nameWithTitle}" ></h:outputLabel>
                                </p:column>

                                <p:column headerText="Date">
                                    <f:facet name="header">
                                        <h:outputLabel value="Date"/>
                                    </f:facet>                                    
                                    <h:outputLabel value="#{ref.createdAt}"  >
                                        <f:convertDateTime pattern="dd/MM/yy" ></f:convertDateTime>
                                    </h:outputLabel>
                                </p:column>

                                <p:column>
                                    <f:facet name="header">
                                        <h:outputLabel value="Payment Methord"/>
                                    </f:facet>                                    
                                    <h:outputLabel value="#{ref.paymentMethod.label}" />
                                </p:column>

                                <p:column headerText="Amount" style="text-align:right;">
                                    <f:facet name="header">
                                        <h:outputLabel value="Amount"/>
                                    </f:facet>                                    
                                    <p:outputLabel value="#{ref.netTotal}" >
                                        <f:convertNumber pattern="#,##0.00" />
                                    </p:outputLabel>
                                </p:column>

                                <p:column headerText="Comment">
                                    <f:facet name="header">
                                        <h:outputLabel value="Comment"/>
                                    </f:facet>                                    
                                    <h:outputLabel  value="#{ref.comments}">
                                    </h:outputLabel>
                                </p:column>

                                <p:columnGroup type="footer">

                                    <p:row>

                                        <p:column colspan="5" footerText="Total"/>
                                        <p:column footerText="#{mdInwardReportController.refundTotal}" style="text-align: right">
                                            <f:facet name="footer">
                                                <p:outputLabel value="#{mdInwardReportController.refundTotal}">
                                                    <f:convertNumber pattern="#,##0.00"></f:convertNumber>
                                                </p:outputLabel>
                                            </f:facet>
                                        </p:column>
                                        <p:column ></p:column>
                                    </p:row>

                                </p:columnGroup>


                            </p:dataTable>

                            <p:panelGrid columns="2" styleClass="noBorder normalFont" style="text-align: right;">
                                <p:outputLabel value="Net Bill Total"/>
                                <p:outputLabel value="#{mdInwardReportController.totalValue}">
                                    <f:convertNumber pattern="#000.00"></f:convertNumber></p:outputLabel>

                                <p:outputLabel value="Net Cancel Bill Total"/>
                                <p:outputLabel value="#{mdInwardReportController.cancelledTotal}">
                                    <f:convertNumber pattern="#000.00"></f:convertNumber></p:outputLabel>

                                <p:outputLabel value="Net Refund Bill Total"/>
                                <p:outputLabel value="#{mdInwardReportController.refundTotal}">
                                    <f:convertNumber pattern="#000.00"></f:convertNumber></p:outputLabel>


                            </p:panelGrid>



                        </h:panelGroup>
                    </p:panel>
                </h:form>


            </ui:define>


        </ui:composition>

    </h:body>
</html>
